package com.espirit.builder.biz;

import com.espirit.eap.manager.ModelBuilderSupport;
import com.espirit.eap.manager.RelatedModel;
import com.espirit.eap.manager.TabbedModel;
import com.espirit.eap.pagelayout.FunctionButton;
import com.espirit.eap.pagelayout.LinkedButton;

//@Component
public abstract class AcctBuilderSupport extends ModelBuilderSupport {
	protected static final String NAME = "name";
	protected static final String ACTIVE = "active";
	protected static final String STRATEGY = "strategy";
	protected static final String DC = "dc";
	protected static final String NBR = "nbr";
	protected static final String REMARK = "remark";
	
	
	@Override
	public boolean init() {
		return true;
	}

	@Override
	public void buildFields() {
		super.buildFields();
		addModelField(NAME, "Name", "名称");
		addModelField(ACTIVE, "Status", "状态");
		addModelField(STRATEGY, "Strategy", "策略");
		addModelField(DC, "DC", "借贷");
		addModelField(NBR, "Number", "顺序");
		addModelField(REMARK, "Remark", "备注");
	}
	
	@Override
	protected void setDefaultLayoutButtons() {
		super.setDefaultLayoutButtons();
		addButton(FunctionButton.IMPORT);
	}
	
	@Override
	protected void addSearchFields() {
		super.addSearchField(convertPropertyToField(NAME, ACTIVE));
	}
	
	@Override
	protected void addListFields() {
		LinkedButton lb = createActiveLinkedButton();
		listElements.add(lb);
		addListField(convertPropertyToField(NAME, STRATEGY, DC, NBR, REMARK));
	}
	
	@Override
	protected void addDetailFields() {
		addDetailField(convertPropertyToField(NAME, ACTIVE, STRATEGY, DC, NBR, REMARK));
	}
	
	@Override
	protected void gatherExproperties() {
		exProperties.put(REQUIRED, new String[]{NAME, DC, STRATEGY, ACTIVE});
	}
	
	protected RelatedModel[] getRelatedModels(){
		RelatedModel getLayout = new RelatedModel(this.clazz, "getLayout");
		return new RelatedModel[]{getLayout};
	}
	
	protected TabbedModel[] getTabbedModels(){
		TabbedModel salaryAcctItems = new TabbedModel(getAcctItemClass(), SEARCH, "parent");
		return new TabbedModel[]{salaryAcctItems};
	}
	
	public abstract Class getAcctItemClass();
}
